library(tidyverse)
library(DT)
library(pander)
library(readr)
library(plotly)
library(ggplot2)
library(mosaic)
library(car)
HSS <- read_csv("../../Data/HighSchoolSeniors.csv")
#Remember: select "Session, Set Working Directory, To Source File Location", and then play this R-chunk into your console to read the HSS data into R.
There were 494 entries after the U.S. Census at School Questionnaire took place with the participants schools of the Census at School Program. The questionnaire had a total of 40 questions to collect information of different aspects like general information, tastes & preferences, skills, etc.
All questions were options and only 471 answered the question where students were tested on how quick they would react using their dominant hand.
The level of significance that we will use for this test is 0.05.
Is there a difference between the average dominant hand reaction time between females and males?
HSS1 <- filter(HSS, !is.na(Reaction_time), !is.na(Gender), !is.na(Travel_to_School), Reaction_time!=15.000, Reaction_time!=35.000, Reaction_time!=34.870, Reaction_time!=7.705, Reaction_time!=6.202, Reaction_time!=6.200, Reaction_time!=4.335)
\[ H_0: \mu_\text{Females Reaction Time} - \mu_\text{Males Reaction Time} = 0 \] \[ H_a: \mu_\text{Females Reaction Time} - \mu_\text{Males Reaction Time} \neq 0 \]
This table contains information about the students who answered the questions to measure their reaction time using their dominant hand. We can see in the table under “Participants” how many students by gender answered the question, and you can compare in the next two columns the Max and Min reaction time by gender,
Based on this table we can see that a female had the longest reaction time of 35sec and a male had the fastest reaction time of 0.01sec. We will see later in there is a difference between the average reaction time between females and males as go though this analysis.
HSS1 |>
group_by(Gender) |>
summarise(Participants=n(), Max_Reaction_Time = max(Reaction_time), Min_Reaction_Time = min(Reaction_time), Mean = mean(Reaction_time), Median = median(Reaction_time)) |>
pander()
| Gender | Participants | Max_Reaction_Time | Min_Reaction_Time | Mean | Median |
|---|---|---|---|---|---|
| Female | 216 | 1.998 | 0.168 | 0.4917 | 0.427 |
| Male | 244 | 2.7 | 0.01 | 0.4199 | 0.357 |
This graph shows the difference and how spread is the data of males and females base on their reaction time using their dominant hand. Something interesting is that the data collected from females is more consistent than the one for males. As we can see in thit boxplot the data for males look more spread.
HS <- HSS1 |>
group_by(Gender) |>
summarise(Max_Reaction_Time = max(Reaction_time), Min_Reaction_Time = min(Reaction_time),
Standard_Dev_Reaction_Time = sd(Reaction_time), Average_Time = mean(Reaction_time))
ggplotly(ggplot(HSS1, aes(x=Gender, y=Reaction_time)) +
geom_boxplot(fill=c("deeppink", "blue"), color="black")+
labs(title="Comparison of Reaction Time by Genre", x="Genre", y="Reaction Time (Seconds)"))
Since we are trying to find if there is a difference between the average reaction time using the dominant hand between males and females, in this scenario we are doing and independent T-test.
In this case both requirement for this kind of test are met:
t.test(Reaction_time~Gender, data=HSS1, m = 0, alternative = "two.sided", conf.level=0.95) |>
pander()
| Test statistic | df | P value | Alternative hypothesis |
|---|---|---|---|
| 3.099 | 455.4 | 0.002063 * * | two.sided |
| mean in group Female | mean in group Male |
|---|---|
| 0.4917 | 0.4199 |
The p-value for this test turned out to be p-value=0.002063 which is lower than the significance level used for this test of 0.05. We reject the null hypotheses of this test and accept the alternative hypotheses to be true. We conclude that based on the calculations and T-test performed for this analysis, there is a difference between the average reaction time when using the dominant hand between males and females.
For this analysis some people had left dominant hand and others had right dominant hand. A future study could be to evaluate and compare the reaction time of males and females depending if they have left or right dominant hand. It will help when it comes to evaluating and comparing the results because people with right dominant hand tent to think and make decision differently than the ones with left dominant hand.